package com.poizon.api;

import com.poizon.bo.CodeBo;
import com.poizon.service.intf.UserService;
import com.poizon.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName UserController
 * @Author NoCheng
 * @Date 2022/1/2 17:21
 * @Description:TODO 用户登录相关
 */

@RestController
@CrossOrigin
@RequestMapping("/api/user/")
@Api(value = "实现登录相关操作",tags = "实现登录相关操作")
public class UserController {
    private final UserService service;

    public UserController(UserService service) {
        this.service = service;
    }

    @ApiOperation(value = "登录操作(首次登录自动注册)")
    @PostMapping("login")
    public R codeLogin(@RequestBody CodeBo bo, HttpServletRequest request){
        return service.login(bo, request.getRemoteAddr());
    }
}
